#ifndef EXPERT_SYSTEM_H_
# define EXPERT_SYSTEM_H_

#include < string >
#include < fstream >
#include < map >
#include < list >
#include < set >
#include < vector >

#include "ICondition.h"
#include "ConditionAnd.h"
#include "ConditionOr.h"
#include "ConditionSimple.h"
#include "ConditionNot.h"
#include "Node.h"

class CExpertSystem
{
public:

	typedef	std::map< std::string, std::string >		MapRules;
	typedef void	( CExpertSystem::*MethodPointer )	( unsigned int , unsigned int );

	typedef std::map< char, Node* >						MapNodes;

	CExpertSystem( const std::string & _strNameFile );
	~CExpertSystem( void );

	void						Start					( void );

private:

	void						Init					( void );
	void						ParseExpertSystemFile	( void );

	Node*						GetNodeById				( char nodeId );
	ConditionSimple*			CreateSimpleConditionFromString	(const std::string& , char& nodeIdCreated);
	void						HandleInitialFact		( const std::string& );
	void						HandleRule				( const std::string& );

	bool						SearchNodeValue			( char nodeId );

	static const std::string	EQUAL;
	static const std::string	IMPLICATE;
	static const std::string	AND;
	static const std::string	OR;
	static const std::string	XOR;
	static const std::string	NOT;
	static const std::string	INITIALFACT;
	static const std::string	RULES;
	static const std::string	SEARCH;

	std::ifstream				m_ifInputFile;
	MapRules					m_mapRules;
	MapNodes					m_mapNodes;
	ConditionsVector			m_vecConditions;
};

#endif //EXPERT_SYSTEM_H_
